'''
@author: 李勇
@contact: 13732546017@163.com
@software: garner
@file: Read_file.py
@time: 2020-01-03 20:01
@desc:  
'''
import sys
import os
import time

sys.path.append(os.path.dirname(os.path.dirname(__file__)))
from tools import Read_file
from tools.Connector_data import *

data_base = Read_file('Data_based_config.yaml')
express_sig_data= Read_file('Add_express.yaml')

class aplum_wms :

    def __init__(self):
        self.db  =  Con_based('Aplum_test')
        # 使用cursor()方法获取操作游标
        self.cursor_salesreture = self.db.cursor()
        self.salesreturn_receive_sql = ""
        self.salesreturn_receive_S = ''
        self.express_sig = express_sig_data["t_express_sign"]
        self.express_sig_values = express_sig_data["t_express_sign_VALUES"]


    def output_string(tup):
        str = ""
        for i in range(len(tup)):
            str += "%s,"
        return str[:-1]


    def t_express_sign(self):

        salesreturn_receive_S = aplum_wms.output_string(self.express_sig_values)
        # 生成sql
        self.salesreturn_receive_sql = "INSERT INTO t_express_sign" + str(tuple(self.express_sig)).replace("\'",
                                                                                                                         "") + "VALUES(" + salesreturn_receive_S + ")"

            # 执行sql语句
        express_sig_data['t_express_sign_VALUES'][2] = time.strftime("%m%d%H%M%S", time.localtime())

        self.cursor_salesreture.execute(self.salesreturn_receive_sql , self.express_sig_values)
        self.db.commit()
        self.db.close()

A = aplum_wms()
A.t_express_sign()
